﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Departments.aspx.vb" Inherits="MyInventory._Departments" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

<asp:Table id="tblTitle" runat="server" width="100%" BorderWidth="0">
<asp:TableRow>
    <asp:TableCell width="100%" HorizontalAlign="Center" BackColor="#000066"><asp:label id="lblTitle" runat="server" ForeColor="White" Font-Bold="True" Font-Size="Large">Text read from Page_Load</asp:label></asp:TableCell>
</asp:TableRow>
</asp:Table>

<hr />


<asp:Table id="tblDetail" runat="server" width="100%" BorderWidth="0">
<asp:TableRow>
    <asp:TableCell>
		<asp:button id="btnAddNew" Text="Add New Department" CssClass="Button" Runat="server" CausesValidation="False"></asp:button>
    </asp:TableCell>

    <asp:TableCell HorizontalAlign="Right">
		<asp:button id="btnRefresh" Text="REFRESH" CssClass="Button" Runat="server" CausesValidation="False"></asp:button>
    </asp:TableCell>

</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Panel id="pnlForm" Visible="False" Runat="server">

	<asp:Table id="Table1" runat="server" width="100%">
        <asp:TableRow>
			<asp:TableCell CssClass="FormLabel" width="15%" HorizontalAlign="Right">Department Name:</asp:TableCell>
			<asp:TableCell CssClass="FormInput">
				<asp:textbox id="txtDepartmentName" runat="server" Columns="42" MaxLength="40" EnableViewState="False"></asp:textbox>&nbsp;
				<asp:RequiredFieldValidator id="rfvName" runat="server" ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtDepartmentName"></asp:RequiredFieldValidator></asp:TableCell>
		</asp:TableRow>
        <asp:TableRow>
			<asp:TableCell CssClass="FormLabel" width="15%" HorizontalAlign="Right">Short Description:</asp:TableCell>
			<asp:TableCell CssClass="FormInput">
				<asp:textbox id="txtShortDesc" runat="server" Columns="80" MaxLength="160" EnableViewState="False"></asp:textbox>&nbsp;
				<asp:RequiredFieldValidator id="rfvshortdesc" runat="server" ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtShortDesc"></asp:RequiredFieldValidator></asp:TableCell>
		</asp:TableRow>
        <asp:TableRow>
			<asp:TableCell CssClass="FormLabel" width="15%" HorizontalAlign="Right">Description:</asp:TableCell>
			<asp:TableCell CssClass="FormInput">
				<asp:textbox id="TxtDescription" runat="server" Columns="80" MaxLength="9192" EnableViewState="False" Rows="5" TextMode="MultiLine"></asp:textbox>&nbsp;
				<asp:RequiredFieldValidator id="rfvdescription" runat="server" ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtDescription"></asp:RequiredFieldValidator></asp:TableCell>
		</asp:TableRow>
		<asp:TableRow>
			<asp:TableCell CssClass="FormLabel" width="15%" HorizontalAlign="Right">Parent:</asp:TableCell>
			<asp:TableCell CssClass="FormInput">
				<asp:textbox id="txtParent" runat="server" Columns="22" MaxLength="20" EnableViewState="False" Text="0"></asp:textbox>&nbsp;
				<asp:RequiredFieldValidator id="rfvsubof" runat="server" ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtParent"></asp:RequiredFieldValidator>
            
               <asp:DropDownList id="lstDepartments" AutoPostBack="True" OnSelectedIndexChanged="Selection_Change" runat="server">

                  <asp:ListItem Selected="True" Value="0"> Root </asp:ListItem>

               </asp:DropDownList>

                </asp:TableCell>
		</asp:TableRow>
		<asp:TableRow>
			<asp:TableCell>&nbsp;</asp:TableCell>
			<asp:TableCell>
				<asp:Button id="btnSave" Text="Save Changes" CssClass="Button" Runat="server"></asp:Button></asp:TableCell>
		</asp:TableRow>
	</asp:Table>

</asp:Panel>

</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
    <asp:TableCell VerticalAlign="Top" Width="100%">
        <asp:datagrid id="dgDepartments" runat="server" AllowPaging="True" AutoGenerateColumns="False" AllowSorting="True" DataKeyField="ID" CellSpacing="2" ShowFooter="False" CellPadding="2" Width="100%">
				<SelectedItemStyle CssClass="DataGrid_SelectedItemStyle" />
				<ItemStyle CssClass="DataGrid_ItemStyle" />
				<AlternatingItemStyle CssClass="DataGrid_AlternatingItemStyle" />
				<HeaderStyle CssClass="DataGrid_HeaderStyle" BackColor="#E4E4E4" />
				<FooterStyle CssClass="DataGrid_FooterStyle" />
				<Columns>
					<asp:BoundColumn DataField="ID" SortExpression="ID" HeaderText="ID" ItemStyle-HorizontalAlign="Right" />
					<asp:BoundColumn DataField="DepartmentName" SortExpression="DepartmentName" HeaderText="Department" ItemStyle-Wrap="False" />
					<asp:BoundColumn DataField="shortdesc" SortExpression="shortdesc" HeaderText="Short Description" />
					<asp:BoundColumn DataField="description" SortExpression="description" HeaderText="Description" />
					<asp:BoundColumn DataField="subof" SortExpression="subof" HeaderText="Parent" ItemStyle-HorizontalAlign="Right" />
					<asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Select" ItemStyle-HorizontalAlign="Center" />
					<asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Select" ItemStyle-HorizontalAlign="Center" />
				</Columns>
				<PagerStyle CssClass="DataGrid_PagerStyle" Mode="NumericPages"  BackColor="#E4E4E4" />
			</asp:datagrid>
			<input id="htmlHiddenSortExpression" type="hidden" value="ID" name="htmlHiddenSortExpression" runat="server"/>	
        </asp:TableCell>
</asp:TableRow>
</asp:Table>
<br />
<span  class="Message">
<asp:label id="lblMsg" runat="server">MSG: <%= strMsg%></asp:label>
</span><br />
<span class="ErrorMessage">
<asp:label id="lblErrorMsg" runat="server">ERROR: <%= strErrorMsg%></asp:label>
</span>

</asp:Content>
